package personal.xzhang.swing.jwizard.sample;

import java.awt.CardLayout;
import java.awt.Container;

import javax.swing.JPanel;

import personal.xzhang.swing.jwizard.JWizardPanel;
import personal.xzhang.swing.jwizard.WizardCards;

public class SampleCards extends WizardCards {

    private final static WizardPanelProxy[] panelProxies_;

    static {
        panelProxies_ = new WizardPanelProxy[2];
        panelProxies_[0] = new WizardPanelProxy("Introduction",
                new IntroPanel(), 0, -1, 1);
        panelProxies_[1] = new WizardPanelProxy("Configuration Complete",
                new CompletePanel(), 1, 0, -1);
    };

    @Override
    public void addComponentToPane(Container pane) {
        cards_ = new JPanel(new CardLayout());

        for (int i = 0; i < 2; i++) {
            WizardPanelProxy proxy = panelProxies_[i];
            proxy.panel_.setTitle(proxy.name_);
            cards_.add(proxy.panel_, proxy.name_);
        }

        pane.add(cards_);
    }

    @Override
    public void showItem(int index) {
        if (index < 0 || index >= panelProxies_.length)
            return;
        CardLayout layout = (CardLayout) cards_.getLayout();
        layout.show(cards_, panelProxies_[index].name_);
        curIndex_ = index;
    }

    @Override
    public JWizardPanel getCurrentPanel() {
        return panelProxies_[curIndex_].panel_;
    }

}
